package com.sskj.xyft.mine;

import com.sskj.xyft.BasePresenter;
import com.sskj.base.utils.RxUtils;
import com.sskj.xyft.api.Api;
import com.sskj.xyft.api.ApiObserver;
import com.sskj.xyft.mine.data.AssetRecord;


/**
 * @author Hey
 * Create at  2019/03/21
 */
class AssetRecordPresenter extends BasePresenter<AssetRecordActivity> {

    public void getAssetRecord(int type, String startTime, String endTime, int page, int pageSize) {
        Api.getInstance().getAssetRecord(type==0?"recharge":"cash", startTime, endTime, page, pageSize)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<AssetRecord>(this, true) {
                    @Override
                    public void onSuccess(AssetRecord data) {
                        mView.setData(data.getRes());
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.stopRefresh();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        mView.setData(null);
                    }
                });

    }

}
